package com.microblogforsim.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.microblogforsim.R;
import com.microblogforsim.model.Message;

import java.util.ArrayList;

public class Message_List_Adapter extends BaseAdapter {
    private Context context;
    private ArrayList<Message> data;

    public Message_List_Adapter(Context context) {
        this.context = context;
    }

    public void replayAll(ArrayList<Message> data){
        if (this.data == null) this.data = new ArrayList<>();
        this.data.addAll(data);
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = View.inflate(context, R.layout.message_list_item,null);
        return convertView;
    }
}
